<template>
	<el-dialog append-to-body class="baseInfoContent" :visible.sync="visible" :title="wStatus ? 'DCU写入数据' : 'DCU保存数据'"
		:close-on-click-modal="false" :close-on-press-escape="false" @close="close" width="800px"
		:top="!wStatus ? '40px' : '120px'">
		<el-form :model="dataForm" ref="dataForm" :rules="dataRule" @keyup.enter.native="confirm()" label-width="140px">
			<el-row>
				<div class="baseInfo1">
					<!-- <el-form-item prop="stationSide" label="站台侧">
						<el-select class="select-form" :disabled="doorAll" v-model="dataForm.stationSide" filterable placeholder="请选择" @change="getStationSide"  style="width:7.2vw; height:3.5vh;min-height: 30px;">
							<el-option v-for="item in options" :key="item.value" :label="item.label"
								:value="item.value">
							</el-option>
						</el-select>
					</el-form-item> -->
					<!-- :required="!(wStatus&&doorAll)" -->
					<el-form-item prop="DCU" label="门控单元编号：" style="margin-bottom: 20px;" :required="!(wStatus && doorAll)">
						<el-select class="select-form" :multiple="doorAll" collapse-tags v-model="dataForm.DCU" filterable
							clearable @change="getdoorChange" placeholder="请选择DCU编号"
							style="width:12.2vw; height:3.5vh;min-height: 30px;">
							<el-checkbox v-if="doorAll" v-model="checkOptions.checkAll" :style="{ paddingLeft: '20px' }"
								:indeterminate="checkOptions.isIndeterminate" @change="handleCheckAllChange">
								全选
							</el-checkbox>
							<el-option v-for="item in DCUoptions" :key="item.dcu" :label="item.dcu" :value="item.dcu">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item prop="CPUType" label="CPU：" style="margin-bottom: 20px;">
						<el-select class="select-form" v-model="dataForm.CPUType" filterable clearable placeholder="请选择CPU"
							@change="getCPUChange" style="width:10.2vw; height:3.5vh;min-height: 30px;">
							<el-option v-for="item in CPUoptions" :key="item.value" :label="item.label" :value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</div>
			</el-row>
			<el-row v-if="!wStatus">
				<el-form-item prop="name" label="DCU保存名称" style="width: 100%;margin-bottom: 20px;">
					<el-input v-model="dataForm.name" placeholder="DCU保存名称" clearable
						style="width:12.2vw; height:3.5vh;min-height: 30px;"></el-input>
				</el-form-item>
			</el-row>
			<!-- <el-row v-if="!wStatus">
				<div class="baseInfo1">
					<el-form-item label="关门时间：">
						<el-input v-model="dataForm.closeTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" v-if="type==1">
						<el-input v-model="dataForm.closeTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type==0?'company1':''">s</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="开门时间：">
						<el-input v-model="dataForm.openTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.openTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type==0?'company1':''">s</span>
				</div>

			</el-row> -->
			<!-- <el-row>
				<div class="baseInfo1">
					<el-form-item label="慢关时间：">
						<el-input v-model="dataForm.slowCloseTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.slowCloseTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type==0?'company1':''">s</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="慢开时间：">
						<el-input v-model="dataForm.slowOpenTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.slowOpenTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type==0?'company1':''">s</span>
				</div>
			</el-row> -->
			<!-- <el-row v-if="!wStatus">
				<div class="baseInfo1">
					<el-form-item label="关门刹车速度：">
						<el-input v-model="dataForm.closeBrakeSpeedLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.closeBrakeSpeedRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" style="right: -20px;">mm/s</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="开门刹车速度：">
						<el-input v-model="dataForm.openBrakeSpeedLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.openBrakeSpeedRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" style="right: -20px;">mm/s</span>
				</div>
			</el-row> -->
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="左门机阻力：">
						<el-input v-model="dataForm.leftNowel" oninput="value=value.replace(/[^\d]/g,'')" placeholder=""
							clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company">N</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="右门机阻力：">
						<el-input v-model="dataForm.rightNowel" oninput="value=value.replace(/[^\d]/g,'')" placeholder=""
							clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company">N</span>
				</div>
			</el-row>
			<el-row v-if="!wStatus">
				<div class="baseInfo1">
					<el-form-item label="关门到位撞击力：">
						<el-input v-model="dataForm.closeImpactLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.closeImpactRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">N</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="开门到位撞击力：">
						<el-input v-model="dataForm.openImpactLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.openImpactRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">N</span>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1" v-if="!wStatus">
					<el-form-item label="遇障力：">
						<el-input v-model="dataForm.encounterNowelLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.encounterNowelRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">N</span>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="关门遇障次数：">
						<el-input v-model="dataForm.closeEncounterNumLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.closeEncounterNumRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">次</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="开门遇障次数：">
						<el-input v-model="dataForm.openEncounterNumLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.openEncounterNumRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">次</span>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="关门遇障等待时间：">
						<el-input v-model="dataForm.closeEncounterTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.closeEncounterTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">s</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="开门遇障等待时间：">
						<el-input v-model="dataForm.openEncounterTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.openEncounterTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">s</span>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1" v-if="!wStatus">
					<el-form-item label="蜂鸣器音量：">
						<el-input v-model="dataForm.buzzerVolumeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.buzzerVolumeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''"
						:style="type == 1 ? 'right: -20px;' : 'right:110px'">档位</span>
				</div>
				<!-- <div class="baseInfo1">
					<el-form-item label="吸锁时间限制：">
						<el-input v-model="dataForm.lockTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type==1">
						<el-input v-model="dataForm.lockTimeRight" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type==0?'company1':''">s</span>
				</div> -->
			</el-row>
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="手解重关时间：">
						<el-input v-model="dataForm.macloseTimeLeft" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.macloseTimeRigth" oninput="value=value.replace(/[^\d]/g,'')"
							placeholder="" clearable style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">s</span>
				</div>
				<div class="baseInfo1" v-if="!wStatus">
					<el-form-item label="生产日期-年：">
						<el-input v-model="dataForm.year" :readonly="true" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="过流保护阈值：">
						<el-input v-model="dataForm.overProThreLeft" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.overProThreRight" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">A</span>
				</div>
				<div class="baseInfo1" v-if="!wStatus">
					<el-form-item label="生产日期-月：">
						<el-input v-model="dataForm.month" :readonly="true" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
				</div>
			</el-row>
			<el-row>
				<div class="baseInfo1">
					<el-form-item label="遇障回退距离：">
						<el-input v-model="dataForm.encounterRegressionDistanceLeft"
							oninput="value=value.replace(/[^\d]/g,'')" placeholder="" clearable
							style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.encounterRegressionDistanceRight"
							oninput="value=value.replace(/[^\d]/g,'')" placeholder="" clearable
							style="width:7.2vw; height:3.5vh;min-height: 30px;"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''"
						:style="type == 1 ? 'right: -10px;' : 'right:101px'">cm</span>
				</div>
			</el-row>
			<el-row v-if="!wStatus">
				<div class="baseInfo1">
					<el-form-item label="端门报警时间：">
						<el-input v-model="dataForm.dmWarnTimeLeft" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<el-form-item class="labelWidth" label="" v-if="type == 1">
						<el-input v-model="dataForm.dmWarnTimeRight" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
					<span class="company" :class="type == 0 ? 'company1' : ''">s</span>
				</div>
				<div class="baseInfo1">
					<el-form-item label="生产日期-日：">
						<el-input v-model="dataForm.date" :readonly="true" placeholder="" clearable
							style="width:7.2vw; height:3.5vh"></el-input>
					</el-form-item>
				</div>
			</el-row>
			<el-row style="display: none;">
				<div class="baseInfo1" v-if="!wStatus">
					<el-form-item label="自学习：">
						<el-checkbox v-model="dataForm.checked"></el-checkbox>
					</el-form-item>
				</div>
			</el-row>
		</el-form>
		<template slot="footer">
			<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
			<el-button class="baseInfoBtn4" type="primary" @click="MRDCU">默认</el-button>
			<el-button class="baseInfoBtn5" type="primary" @click="history">加载</el-button>
			<el-button type="primary" @click="confirm()">{{ $t('confirm') }}</el-button>
		</template>
		<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="init" @getHistory="getHistory">
		</add-or-update>
	</el-dialog>
</template>

<script>
import utils from '@/utils/utils'
import Cookies from 'js-cookie'
import debounce from 'lodash/debounce'
import AddOrUpdate from './oper-add-or-update.vue'
export default {
	components: {
		AddOrUpdate,
	},
	data() {
		// 验证活动名称的函数

		return {
			visible: false,
			options: utils.StationList,
			DCUoptions: [],
			CPUoptions: utils.cpuType,
			type: Cookies.get('type'),
			dataForm: {
				stationSide: 1,
				DCU: '',
				CPUType: '',
				name: '',//保存名字
				leftNowel: '', //门机阻力
				rightNowel: '', //门机阻力
				closeTimeLeft: '', //关门时间
				closeTimeRight: '', //关门时间
				openTimeLeft: '', //开门时间
				openTimeRight: '', //开门时间
				slowCloseTimeLeft: '', //慢关时间
				slowCloseTimeRight: '', //慢关时间
				slowOpenTimeLeft: '', //慢开时间
				slowOpenTimeRight: '', //慢开时间
				closeBrakeSpeedLeft: '', //关门刹车速度
				closeBrakeSpeedRight: '', //关门刹车速度
				openBrakeSpeedLeft: '', //开门刹车速度
				openBrakeSpeedRight: '', //开门刹车速度
				closeImpactLeft: '', //关门到位撞击力
				closeImpactRight: '', //关门到位撞击力
				openImpactLeft: '', //开门到位撞击力
				openImpactRight: '', //开门到位撞击力
				encounterNowelLeft: '', //遇障力
				encounterNowelRight: '', //遇障力
				encounterRegressionDistanceLeft: '', //遇障回退距离
				encounterRegressionDistanceRight: '', //遇障回退距离
				closeEncounterNumLeft: '', //关门遇障次数
				closeEncounterNumRight: '', //关门遇障次数
				openEncounterNumLeft: '', //开门遇障次数
				openEncounterNumRight: '', //开门遇障次数
				closeEncounterTimeLeft: '', //关门遇障等待时间
				closeEncounterTimeRight: '', //关门遇障等待时间
				openEncounterTimeLeft: '', //开门遇障等待时间
				openEncounterTimeRight: '', //开门遇障等待时间
				buzzerVolumeLeft: '', //蜂鸣器音量
				buzzerVolumeRight: '', //蜂鸣器音量
				lockTimeLeft: '', //吸锁时间限制
				lockTimeRight: '', //吸锁时间限制
				macloseTimeLeft: '', //手解重关时间
				macloseTimeRigth: '', //手解重关时间
				year: '', //生产日期-年
				overProThreLeft: '', //过流保护阈值
				overProThreRight: '', //过流保护阈值
				month: '', //生产日期-月
				dmWarnTimeLeft: '', //端门报警时间
				dmWarnTimeRight: '', //端门报警时间
				date: '', //生产日期-日
				checked: false, //自学习
			},
			wStatus: false,
			doorAll: false,//选择所有门
			addOrUpdateVisible: false,
			checkOptions: {
				isIndeterminate: false,
				checkAll: false,
			},
		}
	},
	computed: {
		dataRule() {
			var that = this
			let validateName = (rule, value, callback) => {
				// 当活动名称为空值且为必填时，抛出错误，反之通过校验
				if ((that.dataForm.DCU === "" || that.dataForm.DCU === undefined) && !(that.wStatus && that.doorAll)) {
					callback(new Error("DCU编码不为空"));
				} else {
					callback();
				}
			};
			return {
				DCU: [
					{ validator: validateName, trigger: 'change' }
				],
				CPUType: [
					{ required: true, message: 'CPU编码不为空', trigger: 'blur' }
				],
				name: [
					{ required: true, message: 'DCU保存名称不为空', trigger: 'blur' }
				],
			}
		}
	},
	methods: {
		// 流向全选
		handleCheckAllChange(e) {
			this.dataForm.DCU = e ? this.DCUoptions.map((item) => item.dcu) : []
			this.checkOptions.isIndeterminate = false
		},
		getdoorChange(val) {
			const nowLength = this.dataForm.DCU.length
			this.checkOptions.isIndeterminate =
				nowLength > 0 && nowLength < this.DCUoptions.length
			this.checkOptions.checkAll = nowLength == this.DCUoptions.length
			this.$forceUpdate()
		},
		getCPUChange(val) {
			this.$forceUpdate()
		},
		init(data, val) {
			this.visible = true
			// this.dataForm.stationSide = 1
			this.$nextTick(() => {
				this.$refs['dataForm'].resetFields()
				if (val == 0) {//写DCU
					this.wStatus = true
					this.doorAll = false
					// this.dataRule.stationSide[0].required =  true
					// this.dataRule.DCU[0].required = true
				} else if (val == 1) {//保存DCU
					this.wStatus = false
					this.doorAll = false
					// this.dataRule.stationSide[0].required =  true
					// this.dataRule.DCU[0].required = true
				} else if (val == 2) {//下发所有
					this.wStatus = true
					this.doorAll = true
					// this.dataRule.stationSide[0].required = false
					// this.dataRule.DCU[0].required = false
				}
				//获取门的信息
				var p0 = new Promise((resolve, reject) => {
					this.getdoorList(() => {
						resolve()
					})
				})
				Promise.all([p0]).then(() => {
					this.dataForm = JSON.parse(JSON.stringify(data))
				})
			})
		},
		//获取默认数据
		MRDCU() {
			this.$http.get('/psc/dcuparametersdefault/getParameters').then(res => {
				if (res.data.code == 0) {
					this.getData(res.data.data)
				}
			})
		},
		//获取保存的历史数据
		history() {
			this.addOrUpdateVisible = true
			this.$nextTick(() => {
				this.$refs.addOrUpdate.init()
			})
		},
		//获取历史保存的数据
		getHistory(id) {
			this.$http.get(`/psc/dcuparameters/${id}`).then(res => {
				if (res.data.code == 0 && res.data.data !== null) {
					this.$nextTick(() => {
						this.getData(res.data.data)
					})

					//版本号
				}
			})
		},
		//获取基础参数
		getData(val) {
			this.$set(this.dataForm, 'name', val.name)
			this.$set(this.dataForm, 'CPUType', val.cpuType)
			// this.dataForm.name = val.name
			// this.dataForm.CPUType = val.cpuType
			this.dataForm.leftNowel = val.leftNowel
			this.dataForm.closeTimeLeft = val.closeTimeLeft
			this.dataForm.openTimeLeft = val.openTimeLeft
			this.dataForm.slowCloseTimeLeft = val.slowCloseTimeLeft
			this.dataForm.slowOpenTimeLeft = val.slowOpenTimeLeft
			this.dataForm.closeBrakeSpeedLeft = val.closeBrakeSpeedLeft
			this.dataForm.openBrakeSpeedLeft = val.openBrakeSpeedLeft
			this.dataForm.closeImpactLeft = val.closeImpactLeft
			this.dataForm.openImpactLeft = val.openImpactLeft
			this.dataForm.encounterNowelLeft = val.encounterNowelLeft
			this.dataForm.encounterRegressionDistanceLeft = val.encounterRegressionDistanceLeft
			// this.dataForm.closeAccelerationLeft= val.closeAccelerationLeft
			// this.dataForm.openAccelerationLeft = val.openAccelerationLeft
			// this.dataForm.closeUniformSpeedLeft = val.closeUniformSpeedLeft
			// this.dataForm.openUniformSpeedLeft = val.openUniformSpeedLeft
			// this.dataForm.closeDeAcLeft = val.closeDeAcLeft
			// this.dataForm.openDeAcLeft = val.openDeAcLeft
			this.dataForm.closeEncounterNumLeft = val.closeEncounterNumLeft
			this.dataForm.openEncounterNumLeft = val.openEncounterNumLeft
			this.dataForm.closeEncounterTimeLeft = val.closeEncounterTimeLeft
			this.dataForm.openEncounterTimeLeft = val.openEncounterTimeLeft
			this.dataForm.buzzerVolumeLeft = val.buzzerVolumeLeft
			this.dataForm.lockTimeLeft = val.lockTimeLeft
			this.dataForm.macloseTimeLeft = val.macloseTimeLeft
			this.dataForm.year = val.year
			this.dataForm.overProThreLeft = val.overProThreLeft
			this.dataForm.month = val.month
			this.dataForm.dmWarnTimeLeft = val.dmWarnTimeLeft
			this.dataForm.date = val.day
			this.dataForm.checked = val.checked == 0 ? false : true

			this.dataForm.beforeUnlockTimeLeft = val.beforeUnlockTimeLeft
			this.dataForm.beforeCloseTimeLeft = val.beforeCloseTimeLeft
			this.dataForm.beforeOpenTimeLeft = val.beforeOpenTimeLeft
			this.dataForm.openNumLeft = val.openNumLeft
			this.dataForm.runningHourLeft = val.runningHourLeft
			this.dataForm.encounterNumLeft = val.encounterNumLeft
			this.dataForm.startNumLeft = val.startNumLeft
			if (this.type == 1) {
				this.dataForm.rightNowel = val.rightNowel
				this.dataForm.closeTimeRight = val.closeTimeRight
				this.dataForm.openTimeRight = val.openTimeRight
				this.dataForm.slowCloseTimeRight = val.slowCloseTimeRight
				this.dataForm.slowOpenTimeRight = val.slowOpenTimeRight
				this.dataForm.closeBrakeSpeedRight = val.closeBrakeSpeedRight
				this.dataForm.openBrakeSpeedRight = val.openBrakeSpeedRight
				this.dataForm.closeImpactRight = val.closeImpactRight
				this.dataForm.openImpactRight = val.openImpactRight
				this.dataForm.encounterNowelRight = val.encounterNowelRight
				this.dataForm.encounterRegressionDistanceRight = val.encounterRegressionDistanceRight
				// this.dataForm.closeAccelerationRight = val.closeAccelerationRight
				// this.dataForm.openAccelerationRight = val.openAccelerationRight
				// this.dataForm.closeUniformSpeedRight = val.closeUniformSpeedRight
				// this.dataForm.openUniformSpeedRight = val.openUniformSpeedRight
				// this.dataForm.closeDeAcRight = val.closeDeAcRight
				// this.dataForm.openDeAcRight = val.openDeAcRight
				this.dataForm.closeEncounterNumRight = val.closeEncounterNumRight
				this.dataForm.openEncounterNumRight = val.openEncounterNumRight
				this.dataForm.closeEncounterTimeRight = val.closeEncounterTimeRight
				this.dataForm.openEncounterTimeRight = val.openEncounterTimeRight
				this.dataForm.buzzerVolumeRight = val.buzzerVolumeRight
				this.dataForm.lockTimeRight = val.lockTimeRight
				this.dataForm.macloseTimeRigth = val.macloseTimeRigth
				this.dataForm.overProThreRight = val.overProThreRight
				this.dataForm.dmWarnTimeRight = val.dmWarnTimeRight

				this.dataForm.beforeUnlockTimeRight = val.beforeUnlockTimeRight
				this.dataForm.beforeCloseTimeRight = val.beforeCloseTimeRight
				this.dataForm.beforeOpenTimeRight = val.beforeOpenTimeRight
				this.dataForm.openNumRight = val.openNumRight
				this.dataForm.runningHourRight = val.runningHourRight
				this.dataForm.encounterNumRight = val.encounterNumRight
				this.dataForm.startNumRight = val.startNumRight
			}
		},
		//修改上下行
		getStationSide() {
			this.dataForm.DCU = ''
			this.getdoorList()
		},
		//DCU编号数组
		getdoorList(callback) {
			this.DCUoptions = []
			this.$http.get('/psc/door/getDoor').then(res => {
				this.DCUoptions = []
				this.DCUoptions = res.data.data.up.concat(res.data.data.down)
				for (var i = 0; i < this.DCUoptions.length; i++) {
					if (this.DCUoptions[i].doorType === 0 || this.DCUoptions[i].doorType === 2) {
						this.DCUoptions.splice(i, 1); // 将使后面的元素依次前移，数组长度减1
						i--; // 如果不减，将漏掉一个元素
					}
				}
				callback()
				// if (this.dataForm.stationSide == 1) {
				// 	res.data.data.up.forEach(item => {
				// 		if (item.doorType == 1) {
				// 			this.DCUoptions.push(item)
				// 			if (!this.dataForm.DCU) {
				// 				this.$set(this.dataForm,'DCU',this.DCUoptions[0].dcu)
				// 				// this.dataForm.DCU = this.DCUoptions[0].dcu
				// 			}
				// 		}
				// 	})
				// 	if (callback) {
				// 		callback()
				// 	}
				// } else {
				// 	res.data.data.down.forEach(item => {
				// 		if (item.doorType == 1) {
				// 			this.DCUoptions.push(item)
				// 			if (!this.dataForm.DCU) {
				// 				this.$set(this.dataForm,'DCU',this.DCUoptions[0].dcu)
				// 				// this.dataForm.DCU = this.DCUoptions[0].dcu
				// 			}
				// 		}
				// 	})
				// 	if (callback) {
				// 		callback()
				// 	}
				// }
			})
		},
		close() {
			this.checkOptions = {
				isIndeterminate: false,
				checkAll: false,
			}
			this.dataForm = {
				stationSide: 1,
				DCU: '',
				CPUType: '',
				name: '',//保存名字
				leftNowel: '', //门机阻力
				rightNowel: '', //门机阻力
				closeTimeLeft: '', //关门时间
				closeTimeRight: '', //关门时间
				openTimeLeft: '', //开门时间
				openTimeRight: '', //开门时间
				slowCloseTimeLeft: '', //慢关时间
				slowCloseTimeRight: '', //慢关时间
				slowOpenTimeLeft: '', //慢开时间
				slowOpenTimeRight: '', //慢开时间
				closeBrakeSpeedLeft: '', //关门刹车速度
				closeBrakeSpeedRight: '', //关门刹车速度
				openBrakeSpeedLeft: '', //开门刹车速度
				openBrakeSpeedRight: '', //开门刹车速度
				closeImpactLeft: '', //关门到位撞击力
				closeImpactRight: '', //关门到位撞击力
				openImpactLeft: '', //开门到位撞击力
				openImpactRight: '', //开门到位撞击力
				encounterNowelLeft: '', //遇障力
				encounterNowelRight: '', //遇障力
				encounterRegressionDistanceLeft: '', //遇障回退距离
				encounterRegressionDistanceRight: '', //遇障回退距离
				closeEncounterNumLeft: '', //关门遇障次数
				closeEncounterNumRight: '', //关门遇障次数
				openEncounterNumLeft: '', //开门遇障次数
				openEncounterNumRight: '', //开门遇障次数
				closeEncounterTimeLeft: '', //关门遇障等待时间
				closeEncounterTimeRight: '', //关门遇障等待时间
				openEncounterTimeLeft: '', //开门遇障等待时间
				openEncounterTimeRight: '', //开门遇障等待时间
				buzzerVolumeLeft: '', //蜂鸣器音量
				buzzerVolumeRight: '', //蜂鸣器音量
				lockTimeLeft: '', //吸锁时间限制
				lockTimeRight: '', //吸锁时间限制
				macloseTimeLeft: '', //手解重关时间
				macloseTimeRigth: '', //手解重关时间
				year: '', //生产日期-年
				overProThreLeft: '', //过流保护阈值
				overProThreRight: '', //过流保护阈值
				month: '', //生产日期-月
				dmWarnTimeLeft: '', //端门报警时间
				dmWarnTimeRight: '', //端门报警时间
				date: '', //生产日期-日
				checked: false, //自学习
			}
		},
		confirm: debounce(function () {
			this.$refs['dataForm'].validate((valid) => {
				if (!valid) {
					return false
				}
				if (this.wStatus) {
					var arr = [];
					arr.push(this.dataForm.DCU)
					var obj = {
						dcuArr: this.doorAll ? !this.checkOptions.isIndeterminate ? [] : this.dataForm.DCU : arr,
						cpuType: this.dataForm.CPUType,
						// leftNowel: this.dataForm.leftNowel, //门机阻力
						// rightNowel:this.dataForm.rightNowel,
						slowCloseTimeLeft: this.dataForm.slowCloseTimeLeft, //慢关时间
						slowOpenTimeLeft: this.dataForm.slowOpenTimeLeft, //慢开时间
						encounterRegressionDistanceLeft: this.dataForm.encounterRegressionDistanceLeft, //遇障回退距离
						openEncounterNumLeft: this.dataForm.openEncounterNumLeft, //开门遇障次数阈值
						closeEncounterNumLeft: this.dataForm.closeEncounterNumLeft, //关门遇障次数阈值
						openEncounterTimeLeft: this.dataForm.openEncounterTimeLeft, //开门遇障等待时间(S)
						closeEncounterTimeLeft: this.dataForm.closeEncounterTimeLeft, //关门遇障等待时间(S)
						lockTimeLeft: this.dataForm.lockTimeLeft, //解锁时间限制
						macloseTimeLeft: this.dataForm.macloseTimeLeft, //手动解锁重关时间
						overProThreLeft: this.dataForm.overProThreLeft //过流保护阈值

					}
					this.$http.post('/psc/dcu/writeDcuParams', obj).then(res => {
						if (res.data.code !== 0) {
							return this.$message.error(res.msg)
						}
						this.$message({
							message: this.$t('prompt.success'),
							type: 'success',
							duration: 500,
							onClose: () => {
								this.visible = false
								this.$emit('refreshDataList')
							}
						})
					})
				} else {
					var arr = [];
					arr.push(this.dataForm.DCU)
					if (this.type == 1) {
						var obj = {
							dcuArr: arr,
							cpuType: this.dataForm.CPUType,
							...this.dataForm,
							checked: !this.dataForm.checked ? 0 : 1,
							name: this.dataForm.name,
						}
					} else {
						var obj = {
							dcuArr: arr,
							cpuType: this.dataForm.CPUType,
							leftNowel: this.dataForm.leftNowel, //左门机阻力
							rightNowel: this.dataForm.rightNowel,//右门机阻力
							closeTimeLeft: this.dataForm.closeTimeLeft,
							openTimeLeft: this.dataForm.openTimeLeft,
							slowCloseTimeLeft: this.dataForm.slowCloseTimeLeft, //慢关时间
							slowOpenTimeLeft: this.dataForm.slowOpenTimeLeft, //慢开时间
							closeBrakeSpeedLeft: this.dataForm.closeBrakeSpeedLeft,
							openBrakeSpeedLeft: this.dataForm.openBrakeSpeedLeft,
							closeImpactLeft: this.dataForm.closeImpactLeft,
							openImpactLeft: this.dataForm.openImpactLeft,
							encounterNowelLeft: this.dataForm.encounterNowelLeft,
							encounterRegressionDistanceLeft: this.dataForm.encounterRegressionDistanceLeft, //遇障回退距离
							openEncounterNumLeft: this.dataForm.openEncounterNumLeft, //开门遇障次数阈值
							closeEncounterNumLeft: this.dataForm.closeEncounterNumLeft, //关门遇障次数阈值
							openEncounterTimeLeft: this.dataForm.openEncounterTimeLeft, //开门遇障等待时间(S)
							closeEncounterTimeLeft: this.dataForm.closeEncounterTimeLeft, //关门遇障等待时间(S)
							buzzerVolumeLeft: this.dataForm.buzzerVolumeLeft,
							lockTimeLeft: this.dataForm.lockTimeLeft, //解锁时间限制
							macloseTimeLeft: this.dataForm.macloseTimeLeft, //手动解锁重关时间
							overProThreLeft: this.dataForm.overProThreLeft, //过流保护阈值
							year: this.dataForm.year,
							month: this.dataForm.month,
							date: this.dataForm.date,
							dmWarnTimeLeft: this.dataForm.dmWarnTimeLeft,
							checked: !this.dataForm.checked ? 0 : 1,
							beforeUnlockTimeLeft: this.dataForm.beforeUnlockTimeLeft,
							beforeCloseTimeLeft: this.dataForm.beforeCloseTimeLeft,
							beforeOpenTimeLeft: this.dataForm.beforeOpenTimeLeft,
							openNumLeft: this.dataForm.openNumLeft,
							runningHourLeft: this.dataForm.runningHourLeft,
							encounterNumLeft: this.dataForm.encounterNumLeft,
							startNumLeft: this.dataForm.startNumLeft,
							name: this.dataForm.name,
						}
					}
					this.$http.post('/psc/dcuparameters', obj).then(res => {
						if (res.data.code !== 0) {
							return this.$message.error(res.msg)
						}
						this.$message({
							message: this.$t('prompt.success'),
							type: 'success',
							duration: 500,
							onClose: () => {
								this.visible = false
								this.$emit('refreshDataList')
							}
						})
					})
				}
			})

		})
	}
}
</script>

<style scoped>
.baseInfoContent>>>.el-row {
	display: flex;
	/* justify-content: space-between; */
}

.baseInfo1 {
	width: 50%;
	display: flex;
	justify-content: flex-start;
	align-items: center;
	position: relative;
}

.baseInfo1>>>.el-form-item__label {
	/* width: 11vw; */
	width: 150px;
	font-size: 14px;
	font-weight: 400;
	color: rgba(46, 48, 51, 1);
}

.select-form>>>.el-input {
	height: 100% !important;
	display: flex;
}

.baseInfoContent>>>.el-form--inline .el-form-item__content,
.el-form--inline .el-form-item {
	vertical-align: middle !important;
}

.baseInfo1>>>.el-form-item {
	/* width: 100%!important; */
}

.labelWidth>>>.el-form-item__content {
	margin-left: 10px !important;
}

.baseInfo1 .company {
	/* height: 2.7vh;
		line-height: 2.7vh;
		margin-top: 0.8vh; */
	/* font-size: 16px;
		position: absolute;
		right: 0px; */
	padding-left: 10px;
}

.baseInfo1 .company1 {
	/* right: 110px; */
}

.baseInfoBtn4 {
	background: rgba(56, 56, 56, 1) !important;
	border-color: rgba(56, 56, 56, 1) !important;
}

.baseInfoBtn4:focus,
.baseInfoBtn4:hover {
	background: rgba(56, 56, 56, 1) !important;
	border-color: rgba(56, 56, 56, 1) !important;
}

.baseInfoBtn5 {
	background: rgba(255, 141, 26, 1) !important;
	border-color: rgba(255, 141, 26, 1) !important;
}

.baseInfoBtn5:focus,
.baseInfoBtn5:hover {
	background: rgba(255, 141, 26, 1) !important;
	border-color: rgba(255, 141, 26, 1) !important;
}
</style>
